package cn.ulc.socket.admin.controller;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import cn.ulc.common.model.param.PaginationParam;
import cn.ulc.common.util.Result;
import cn.ulc.socket.admin.model.dto.member.WxUserListDTO;
import cn.ulc.socket.admin.model.dto.order.OrderListDTO;
import cn.ulc.socket.admin.model.param.deposit.BackBucketParam;
import cn.ulc.socket.admin.service.deposit.DepositServ;
import cn.ulc.socket.admin.service.order.OrderServ;
import cn.ulc.socket.common.api.WxPayAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "/deposits")
public class DepositCtrl {
    private static final Log log = LogFactory.get();

    @Autowired
    DepositServ depositServ;
    @Autowired
    WxPayAPI wxPayAPI;

    @GetMapping
    public Result findListPage(String key, PaginationParam pager) {
        WxUserListDTO dto = depositServ.findDepositList(key ,pager);
        return Result.success(dto);
    }
    @PutMapping("/backBucket")
    public Result backBucket(@Validated @RequestBody BackBucketParam param, BindingResult result){
        if(result.hasErrors()) {
            log.error("退桶",result.getFieldError().getDefaultMessage());
            return Result.fail(result.getFieldError().getDefaultMessage());
        }
        return Result.success(depositServ.backBucket(param),true);
    }
}
